#include <stdbool.h>

void sieve(unsigned long * num, unsigned long n)
{
	unsigned long i = 0, j = 0;
	unsigned long cur = 0;
	bool flag;
	for (i = 0; i < n; ++i)
		num[i] = 0;
	for (i = 1; cur < n; ++i) {
		flag = true;
		for (j = 1; j < cur; ++j)
			if ((i % num[j] == 0) && (num[j] != 1)) {
				flag = false;
			}
		if (flag)
			num[cur++] = i;
	}
}
